$(function () {
    share();
    //TODO:获取信息
    $.ajax({
        url:host+'/CMSAPI/GetChannel?openid='+openid+'&cid='+cid,
        type:'GET',
        success:function(data){
            if(data.state){
                var main=data.data;
                var RealName=main.RealName||'';
                var Phone=main.Phone||'';
                $('.name>span').html(RealName);
                $('.phone>span').html(Phone);
            }
        }
    })
    //TODO:获取信息，主要是邀请码
    $.ajax({
        url:host+'/CMSAPI/GetChannel?openid='+openid+'&cid='+cid,
        success:function(data){
            if(data.state){
                var Number=data.data.Number;
                $('.inviteCode').html('我的邀请码：'+Number)
            }
        }
    })
    //TODO:点击li进入修改页面，同时要记住当前点击的是什么list项
    $('.centerList').on('click','li',function(){
        var listName=$(this).attr('data-list');
        var title=$(this).attr('data-title');
        var info=$(this).find('.info').html();
        if(listName!=='pwd'){
            window.location.href='modify.html?listName='+listName+'&info='+info+'&title='+title;
        }else {
            window.location.href='changePwd.html';
        }
    })
    $('.exit-btn').click(function () {
        $.Dialog({
            type: 'confirm',
            textColor: '#2c2c2c',
            content: '退出后将需要重新登录，确定退出吗？',
            callBack: function () {
                $.ajax({
                    url: host + 'mtmlapi/Logout',
                    type: 'POST',
                    data: {
                        openid: openid,
                        cid: cid,
                        ispartner: false
                    },
                    success: function (res) {
                        if (res.state) {
                            window.localStorage.clear()
                            $.Dialog({content: res.message})
                            setTimeout(function () {
                                window.open('login.html')
                            }, 1000)
                        } else {
                            $.Dialog({content: res.message})
                        }
                    }
                })
            }
        })
    })
})
